package com.zhy.sunmi.bean;

import com.zhy.greendao.gen.DaoSession;
import com.zhy.greendao.gen.SellGoodHistoryDao;
import com.zhy.greendao.gen.SoldGoodDetailDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Transient;

import java.util.List;

/**
 * @ClassName SellGoodHistory
 * @Description TODO
 * @Author zhouhongyang
 * @DATE 2021/9/28 11:30 下午
 * @Version 1.0
 */

@Entity
public class SellGoodHistory {

    /**
     * 订单id
     * [
     * 商品id
     * 英文名
     * 中文名
     * 商品数量
     * 商品价格
     * 商品折扣(打几折)
     * 商品折扣（省多少钱）
     * 单价
     * 总价
     * 税率(百分比)
     * 税率(多少钱)
     * ]
     * 商品总价（未打折满减前）
     * 实际应支付
     * 商品类数
     * 商品总折扣(省多少钱)
     * 商品note
     * 打折券id(打几折)
     * 打折券id(满减)
     * 总税额
     * 支付方式
     * 收银员id
     * 收银机id
     * 时间
     * 支付方式
     * 支付多少（给多少 现金可大于实际应支付）
     * 找零多少
     * 客户id
     * 状态（void cancel selled）
     * 银行卡字段
     * （
     * 收银回执大概4个
     * ）
     */

    @Id(autoincrement = true)
    //主键id
    private Long id;
    //订单号
    private String orderCode;
    //收银员id
    private long cashierId;
    //收银机id
    private long cashRegisterId;
    //商品总数
    private int totalNumber;
    //顾客编号
    private String customerCode;
    //订单备注note
    private String remarks;
    //支付方式 （0 未支付；1 现金；2 卡支付；3 阿里支付；4 微信支付；）
    private int paymentMethod;
    //订单总金额（原价未经过任何减价）
    private String totalMoney;
    //订单打折后金额
    private String totalMoneyAfterDiscount;
    //订单总税额
    private String totalVat;
    //订单总优惠
    private String totalSave;
    //支付状态（0 支付完成；1 Cancel；2 Void；3 Hold 4 Refund 5 去支付）
    private int payStatus;
    //订单完成时间（时间戳）
    private long payTime;
    //找零金额
    private String changeMoney;
    //实际支付金额（现金支付金额可能大于实际应付款）
    private String actualPayMoney;
    //优惠券编号打折
    private String discountOffCode;
    //优惠券编号减免
    private String dicountRemCode;
    //支付结果主要是卡支付返回用
    private String payResult;
    //是否上传服务器成功
    private boolean portSuccess;

    @Transient
    private List<SoldGoodDetail> soldGoodDetailList;

    

    @ToMany(referencedJoinProperty = "sellGoodHistoryId")
    private List<SoldGoodDetail> soldGoodDetails;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 1669683100)
    private transient SellGoodHistoryDao myDao;



    @Generated(hash = 254319401)
    public SellGoodHistory(Long id, String orderCode, long cashierId, long cashRegisterId,
            int totalNumber, String customerCode, String remarks, int paymentMethod, String totalMoney,
            String totalMoneyAfterDiscount, String totalVat, String totalSave, int payStatus,
            long payTime, String changeMoney, String actualPayMoney, String discountOffCode,
            String dicountRemCode, String payResult, boolean portSuccess) {
        this.id = id;
        this.orderCode = orderCode;
        this.cashierId = cashierId;
        this.cashRegisterId = cashRegisterId;
        this.totalNumber = totalNumber;
        this.customerCode = customerCode;
        this.remarks = remarks;
        this.paymentMethod = paymentMethod;
        this.totalMoney = totalMoney;
        this.totalMoneyAfterDiscount = totalMoneyAfterDiscount;
        this.totalVat = totalVat;
        this.totalSave = totalSave;
        this.payStatus = payStatus;
        this.payTime = payTime;
        this.changeMoney = changeMoney;
        this.actualPayMoney = actualPayMoney;
        this.discountOffCode = discountOffCode;
        this.dicountRemCode = dicountRemCode;
        this.payResult = payResult;
        this.portSuccess = portSuccess;
    }



    @Generated(hash = 1961427663)
    public SellGoodHistory() {
    }



    public Long getId() {
        return this.id;
    }



    public void setId(Long id) {
        this.id = id;
    }



    public String getOrderCode() {
        return this.orderCode;
    }



    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }



    public long getCashierId() {
        return this.cashierId;
    }



    public void setCashierId(long cashierId) {
        this.cashierId = cashierId;
    }



    public long getCashRegisterId() {
        return this.cashRegisterId;
    }



    public void setCashRegisterId(long cashRegisterId) {
        this.cashRegisterId = cashRegisterId;
    }



    public int getTotalNumber() {
        return this.totalNumber;
    }



    public void setTotalNumber(int totalNumber) {
        this.totalNumber = totalNumber;
    }



    public String getCustomerCode() {
        return this.customerCode;
    }



    public void setCustomerCode(String customerCode) {
        this.customerCode = customerCode;
    }



    public String getRemarks() {
        return this.remarks;
    }



    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }



    public int getPaymentMethod() {
        return this.paymentMethod;
    }



    public void setPaymentMethod(int paymentMethod) {
        this.paymentMethod = paymentMethod;
    }



    public String getTotalMoney() {
        return this.totalMoney;
    }



    public void setTotalMoney(String totalMoney) {
        this.totalMoney = totalMoney;
    }



    public String getTotalMoneyAfterDiscount() {
        return this.totalMoneyAfterDiscount;
    }



    public void setTotalMoneyAfterDiscount(String totalMoneyAfterDiscount) {
        this.totalMoneyAfterDiscount = totalMoneyAfterDiscount;
    }



    public String getTotalVat() {
        return this.totalVat;
    }



    public void setTotalVat(String totalVat) {
        this.totalVat = totalVat;
    }



    public String getTotalSave() {
        return this.totalSave;
    }



    public void setTotalSave(String totalSave) {
        this.totalSave = totalSave;
    }



    public int getPayStatus() {
        return this.payStatus;
    }



    public void setPayStatus(int payStatus) {
        this.payStatus = payStatus;
    }



    public long getPayTime() {
        return this.payTime;
    }



    public void setPayTime(long payTime) {
        this.payTime = payTime;
    }



    public String getChangeMoney() {
        return this.changeMoney;
    }



    public void setChangeMoney(String changeMoney) {
        this.changeMoney = changeMoney;
    }



    public String getActualPayMoney() {
        return this.actualPayMoney;
    }



    public void setActualPayMoney(String actualPayMoney) {
        this.actualPayMoney = actualPayMoney;
    }



    public String getDiscountOffCode() {
        return this.discountOffCode;
    }



    public void setDiscountOffCode(String discountOffCode) {
        this.discountOffCode = discountOffCode;
    }



    public String getDicountRemCode() {
        return this.dicountRemCode;
    }



    public void setDicountRemCode(String dicountRemCode) {
        this.dicountRemCode = dicountRemCode;
    }


    public List<SoldGoodDetail> getSoldGoodDetailList() {
        return soldGoodDetailList;
    }

    public void setSoldGoodDetailList(List<SoldGoodDetail> soldGoodDetailList) {
        this.soldGoodDetailList = soldGoodDetailList;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 410890396)
    public List<SoldGoodDetail> getSoldGoodDetails() {
        if (soldGoodDetails == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SoldGoodDetailDao targetDao = daoSession.getSoldGoodDetailDao();
            List<SoldGoodDetail> soldGoodDetailsNew = targetDao
                    ._querySellGoodHistory_SoldGoodDetails(id);
            synchronized (this) {
                if (soldGoodDetails == null) {
                    soldGoodDetails = soldGoodDetailsNew;
                }
            }
        }
        return soldGoodDetails;
    }



    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1981792857)
    public synchronized void resetSoldGoodDetails() {
        soldGoodDetails = null;
    }



    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }



    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }



    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }



    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1238390291)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getSellGoodHistoryDao() : null;
    }



    @Override
    public String toString() {
        return "SellGoodHistory{" +
                "id=" + id +
                ", orderCode='" + orderCode + '\'' +
                ", cashierId=" + cashierId +
                ", cashRegisterId=" + cashRegisterId +
                ", totalNumber=" + totalNumber +
                ", customerCode='" + customerCode + '\'' +
                ", remarks='" + remarks + '\'' +
                ", paymentMethod=" + paymentMethod +
                ", totalMoney='" + totalMoney + '\'' +
                ", totalMoneyAfterDiscount='" + totalMoneyAfterDiscount + '\'' +
                ", totalVat='" + totalVat + '\'' +
                ", totalSave='" + totalSave + '\'' +
                ", payStatus=" + payStatus +
                ", payTime=" + payTime +
                ", changeMoney='" + changeMoney + '\'' +
                ", actualPayMoney='" + actualPayMoney + '\'' +
                ", discountOffCode='" + discountOffCode + '\'' +
                ", dicountRemCode='" + dicountRemCode + '\'' +
                ", soldGoodDetails=" + soldGoodDetails +
                ", daoSession=" + daoSession +
                ", myDao=" + myDao +
                '}';
    }



    public String getPayResult() {
        return this.payResult;
    }



    public void setPayResult(String payResult) {
        this.payResult = payResult;
    }



    public boolean getPortSuccess() {
        return this.portSuccess;
    }



    public void setPortSuccess(boolean portSuccess) {
        this.portSuccess = portSuccess;
    }
}
